/**
* 作者: lichuan
* 日期: 2025-07-08 12:03:22
* 备注: 玩家高级签到详情表
*/
package com.motu.monstercity.server.game.userdata;

import com.motu.monstercity.server.game.base.AllParam;
import com.motu.monstercity.server.game.commondata.act.DailyPass;
import com.motu.monstercity.server.game.logic.ActManager;
import com.motu.monstercity.server.game.logic.GameUser;
import com.motu.vertx.module.utility.toolset.TimeUtils;
import io.vertx.core.json.JsonObject;

import java.util.List;

public class UserDailyPass extends UserDailyPassModel {
	public UserDailyPass() {
		super();
	}


	public JsonObject insert() {
		putGroupId(ActManager.getDailyPassStartGroupId());
		putResetTime(TimeUtils.getCurTime());
		return super.insert();
	}

	public void reset() {
		int nextGroupId = ActManager.getDailyPassNextGroupId(groupId);
		if(nextGroupId <= 0){
			return;
		}
		DailyPass configByGroupId = ActManager.getDailyPassConfigByGroupId(groupId);
		if (configByGroupId == null) {
			return;
		}
		UserExtInfo userExtInfo = GameUser.getUserExtInfo(getId());
		long endTime = ActManager.getDailyPassEndTime(userExtInfo.getRegisterTime(), configByGroupId); // 获取最后期数的时间


		// 当期最后的时间到了 隔天才重置
		if (!TimeUtils.isToday(getResetTime()) && TimeUtils.getCurTime() >= endTime && nextGroupId != groupId) {
			putGroupId(nextGroupId);
			putResetTime(TimeUtils.getCurTime());
			putSignList("");
			putSignList2("");
			update();
		}
	}


	public boolean isFinishPass(){
		int nextGroupId = ActManager.getDailyPassNextGroupId(groupId);
        return nextGroupId <= 0;
    }

}
